﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;

namespace GPCSC.Webs

{
    public class SendEmail
    {
        public SendEmail()
        { 
        
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="acpUserMail">发件人地址</param>
        /// <param name="ToMails">收件人地址</param>
        /// <param name="message">内容</param>
        /// <param name="title">主题</param>
        /// <param name="username">我的用户名</param>
        /// <param name="password">我的密码</param>
        /// <param name="smtp">主机IP地址</param>
        public void sendMails(string acpUserMail, string ToMails, string message, string title, string username, string password, string smtp)
        {



            MailMessage mail = new MailMessage();

            MailAddress add = new MailAddress(acpUserMail);
            //foreach (string tomail in ToMails)
            //{
            mail.To.Add(new MailAddress(ToMails));
            //}
            mail.From = add;

            mail.Subject = title; //主题
            mail.Body = message;  //内容
            mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");

            mail.IsBodyHtml = true;
            mail.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient();
            //设置用于 SMTP 事务的主机的名称，填IP地址也可以了
            client.Host = "smtp.163.com";
            //设置用于 SMTP 事务的端口，默认的是 25
            //client.Port = 25;
            client.UseDefaultCredentials = false;
            //这里才是真正的邮箱登陆名和密码，比如我的邮箱地址是 hbgx@hotmail， 我的用户名为 hbgx ，我的密码是 xgbh
            client.Credentials = new System.Net.NetworkCredential(username, password);
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            //都定义完了，正式发送！
            client.Send(mail);
        }


    }
}